package cn.piesat.scanning.service.impl;

import cn.piesat.scanning.service.AlgorithmExecService;
import cn.piesat.scanning.utils.BeanUtil;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

import java.lang.reflect.Method;

/**
 * @author xhl
 */
@Service
public class AlgorithmExecServiceImpl implements AlgorithmExecService {

    @Value("${ht.datahandle.service.class}")
    private String className;
//    @Async
    @Override
    public void init(String taskId) {
        try {
            Class<?> aClass = Class.forName(className);
            Method method = aClass.getMethod("selectAlgorithm", String.class);
            method.invoke(BeanUtil.getBean(aClass),taskId);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Override
    public void redo(String recordId) {
        try {
            Class<?> aClass = Class.forName(className);
            Method method = aClass.getMethod("redo", String.class);
            method.invoke(BeanUtil.getBean(aClass),recordId);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }


}
